print('Введите скобочную последовательность')
scob = input()
g = ''
if  (scob in '())'or scob in ')()') or (scob in '[]]' or scob in '][]') or\
    ((scob in '{}}' or scob in '}{}') or (scob in '<>>' or scob in '><>')):
        print('false')
else:
    for ch in scob:
        if ch == '(':
            g += ch

        if ch == ')':
            if len(g) > 0:
                if g[len(g) - 1] == '(':
                    g = g[: -1]

        if ch == '[':
            g += ch

        if ch == ']':
            if len(g) > 0:
                if g[len(g) - 1] == '[':
                    g = g[: -1]

        if ch == '{':
            g += ch

        if ch == '}':
            if len(g) > 0:
                if g[len(g) - 1] == '{':
                    g = g[: -1]

        if ch == '<':
            g += ch

        if ch == '>':
            if len(g) > 0:
                if g[len(g) - 1] == '<':
                    g = g[: -1]
                    
        
        print(g)

    print(g)

    if len(g) == 0:
        print('True')
    else:
        print('False')
    
            
